<?php
	header('Content-Type:text/html;Charset=utf-8');
	header("Access-Control-Allow-Origin:*");
	header("Access-Control-Allow-Methods:GET,POST");

	$loginname=$_REQUEST["txtLoginName"];
	$loginpwd=$_REQUEST["txtLoginPwd"];
	$conn=mysqli_connect("127.0.0.1","root","root","process");
	// mysqli_query($conn,'SET NAMES utf8');
	$query_str="select * from user WHERE username='$loginname' and pwd='$loginpwd'";
	$result=mysqli_query($conn,$query_str);
	if($result){
		$result_count=mysqli_num_rows($result);
		if($result_count>0){
			//登录成功
			if($row = mysqli_fetch_row($result)){
				$uid=$row[0];
				$username=$row[1];
				$json_array=array("uid"=>$uid,"username"=>$username);
				echo json_encode($json_array);
			}
		}else{
			echo "ERROR";
		}
	}else{
		echo "SERVER_ERROR";
	}
?>